package com.xl6667.controller;

import com.xl6667.constants.SystemConstants;
import com.xl6667.domain.ResponseResult;
import com.xl6667.domain.entity.Comment;
import com.xl6667.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/comment")
public class CommentController {
    @Autowired
    private CommentService commentService;

    /**
     * 获取文章评论
     * @param articleId
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/commentList")
    public ResponseResult commentList(Integer articleId, Integer pageNum, Integer pageSize){
        return commentService.commentList(SystemConstants.ARTICLE_COMMENT,articleId,pageNum,pageSize);
    }

    /**
     * 获取友链评论
     * @param pageNum
     * @param pageSize
     * @return
     */

    @GetMapping("/linkCommentList")
    public ResponseResult linkCommentList(Integer pageNum, Integer pageSize){
        return commentService.commentList(SystemConstants.LINK_COMMENT,null,pageNum,pageSize);
    }

    /**
     * 添加评论
     * @param comment
     * @return
     */

    @PostMapping()
    public ResponseResult addComment(@RequestBody Comment comment){
       return commentService.addComment(comment);
    }

}
